package org.scmpatrol.scm.connector.svn;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.io.ISVNReporter;
import org.tmatesoft.svn.core.io.ISVNReporterBaton;
import org.scmpatrol.scm.action.SCMAction;
import org.scmpatrol.scm.action.SCMActionTypeEnum;

public class SVNReporterBaton implements ISVNReporterBaton {
    public final static Logger LOGGER = Logger.getLogger(SVNReporterBaton.class.getName());

    private long revision;
    List<SCMAction> actions;

    public SVNReporterBaton(String revision) {
        this.revision = Long.valueOf(revision);
    }

    public void setActions(List<SCMAction> actions) {
        this.actions = actions;
    }

    public void report(ISVNReporter reporter) throws SVNException {
        LOGGER.info(reporter.toString());
        try {
            reporter.setPath("", null, revision - 1, SVNDepth.INFINITY, false);

            reporter.finishReport();
        } catch (SVNException svne) {
            LOGGER.error("Erreur reporting", svne);
            reporter.abortReport();
            throw svne;
        }
    }

}

